package com.dhcc.core.modules.msgcenter.controller;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.plugins.Page;
import com.dhcc.core.framework.base.controller.BaseController;
import com.dhcc.core.framework.result.R;
import com.dhcc.core.framework.result.page.PageFactory;
import com.dhcc.core.modules.msgcenter.cache.MsgCache;
import com.dhcc.core.modules.msgcenter.entity.MsgPushLog;
import com.dhcc.core.modules.msgcenter.service.IMsgPushLogService;
import com.dhcc.core.modules.msgcenter.warpper.MsgPushLogWarpper;


/**
 * 消息推送记录
 * 
 * @ClassName: MsgPushLogController
 * @Description: TODO
 * @author cyf
 * @date 2018-11-15 15:02:17
 */
@Controller
@RequestMapping("${sys.backendPath}/msgcenter/pushlog")
public class MsgPushLogController extends BaseController {

	private String PREFIX = "/backend/msgcenter/pushlog/";

	@Autowired
	private IMsgPushLogService msgPushLogService;
	

    /**
     * 跳转到消息推送记录列表首页
     */
    @RequestMapping("")
    public String index(Model model) {
        model.addAttribute("pushTypes", MsgCache.me().getPushTypes());
        return PREFIX + "pushlog.html";
    }
	
    /**
     * 获取消息推送记录列表
     */
	@SuppressWarnings("unchecked")
    @RequestMapping(value = "/list")
    @ResponseBody
    public Object list(@RequestParam Map<String, Object> params) {
		Page<MsgPushLog> page = new PageFactory<MsgPushLog>().defaultPage();
        List<MsgPushLog> result = this.msgPushLogService.page(page,params);
        page.setRecords((List<MsgPushLog>) new MsgPushLogWarpper(result).warp());
        return R.packForBT(page);
    }
	
}
